package net.gxnun.xiaoyuan.core.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MyStringUtils {
    
  //首字母转小写
    public static String toLowerCaseFirstOne(String s)
    {
        if(Character.isLowerCase(s.charAt(0)))
            return s;
        else
            return (new StringBuilder()).append(Character.toLowerCase(s.charAt(0))).append(s.substring(1)).toString();
    }
    //首字母转大写
    public static String toUpperCaseFirstOne(String s)
    {
        if(Character.isUpperCase(s.charAt(0)))
            return s;
        else
            return (new StringBuilder()).append(Character.toUpperCase(s.charAt(0))).append(s.substring(1)).toString();
    }
    
    
    //用正则去字符串某一段字符
    public static String getWordByReg(String reg,String resource){
        String word = "";
        Matcher m = Pattern.compile(reg).matcher(resource);  
        if (m.find()) {  
            word = m.group(0); 
        }  
        return word;
    }
    
}
